<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/saiki.jpeg?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/saiki.jpeg?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="linux,">










<meta name="description" content="我们可以通过ls -l命令来显示当前目录下文件的属性123456 playcrab@shenpeng  ~/KOs/meta  ls -ltotal 24-rw-------@ 1 playcrab  staff  6703 May 14 20:25 check.pydrwxr-xr-x  9 playcrab  staff   288 May 15 16:46 config-rw------">
<meta name="keywords" content="linux">
<meta property="og:type" content="article">
<meta property="og:title" content="linux文件属性">
<meta property="og:url" content="http://yoursite.com/2020/06/14/linux文件属性/index.html">
<meta property="og:site_name" content="Penn">
<meta property="og:description" content="我们可以通过ls -l命令来显示当前目录下文件的属性123456 playcrab@shenpeng  ~/KOs/meta  ls -ltotal 24-rw-------@ 1 playcrab  staff  6703 May 14 20:25 check.pydrwxr-xr-x  9 playcrab  staff   288 May 15 16:46 config-rw------">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-06-14T09:13:09.374Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="linux文件属性">
<meta name="twitter:description" content="我们可以通过ls -l命令来显示当前目录下文件的属性123456 playcrab@shenpeng  ~/KOs/meta  ls -ltotal 24-rw-------@ 1 playcrab  staff  6703 May 14 20:25 check.pydrwxr-xr-x  9 playcrab  staff   288 May 15 16:46 config-rw------">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":true},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2020/06/14/linux文件属性/">





  <title>linux文件属性 | Penn</title>
  








</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Penn</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">my blog</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-schedule">
          <a href="/schedule/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br>
            
            日程表
          </a>
        </li>
      
        
        <li class="menu-item menu-item-sitemap">
          <a href="/sitemap.xml" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br>
            
            站点地图
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/06/14/linux文件属性/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Shen">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/saiki.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Penn">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">linux文件属性</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-06-14T17:13:09+08:00">
                2020-06-14
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/categories/技术/" itemprop="url" rel="index">
                    <span itemprop="name">技术</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2020/06/14/linux文件属性/" class="leancloud_visitors" data-flag-title="linux文件属性">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>我们可以通过<code>ls -l</code>命令来显示当前目录下文件的属性<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"> playcrab@shenpeng  ~/KOs/meta  ls -l</span><br><span class="line">total 24</span><br><span class="line">-rw-------@ 1 playcrab  staff  6703 May 14 20:25 check.py</span><br><span class="line">drwxr-xr-x  9 playcrab  staff   288 May 15 16:46 config</span><br><span class="line">-rw-------@ 1 playcrab  staff   285 May 14 21:08 config.ini</span><br><span class="line">drwxr-xr-x@ 7 playcrab  staff   224 May 15 16:46 dtonline</span><br></pre></td></tr></table></figure></p>
<h4 id="第一栏-drwxr-xr-x"><a href="#第一栏-drwxr-xr-x" class="headerlink" title="第一栏 drwxr-xr-x"></a>第一栏 <code>drwxr-xr-x</code></h4><h5 id="文件类型"><a href="#文件类型" class="headerlink" title="文件类型"></a>文件类型</h5><p>第一个字符代表这个文件是『目录、文件或链接文件等等』：</p>
<ul>
<li>当为[ d ]则是目录，例如上表档名为『.gconf』的那一行；</li>
<li>当为[ - ]则是文件，例如上表档名为『install.log』那一行；</li>
<li>若是[ l ]则表示为连结档(link file)；</li>
<li>若是[ b ]则表示为装置文件里面的可供储存的接口设备(可随机存取装置)；</li>
<li>若是[ c ]则表示为装置文件里面的串行端口设备，例如键盘、鼠标(一次性读取装置)。</li>
</ul>
<h5 id="不同用户对文件的权限"><a href="#不同用户对文件的权限" class="headerlink" title="不同用户对文件的权限"></a>不同用户对文件的权限</h5><p>接下来的字符中，以三个为一组，且均为『rwx』 的三个参数的组合。分别表示<code>文件拥有者的权限</code>、<code>拥有者所属组的组员的权限</code>和<code>其他用户的权限</code>.<br></p>
<ol>
<li>其中，[ r ]代表可读(read)、[ w ]代表可写(write)、[ x ]代表可执行(execute)。 要注意的是，这三个权限的位置不会改变，如果没有权限，就会出现减号[ - ]而已。</li>
<li>还可以用数字来表三每组权限:r=4,w=2,x=1<ul>
<li>rwx权限等同于 4+2+1= 7</li>
<li>rw-权限等同于 4+2= 6   </li>
<li>r-x权限等同于 4+1= 5</li>
<li>…</li>
</ul>
</li>
</ol>
<h5 id="可以通过chmod命令来执行权限-如"><a href="#可以通过chmod命令来执行权限-如" class="headerlink" title="可以通过chmod命令来执行权限,如:"></a>可以通过chmod命令来执行权限,如:</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod ug=wx,o=x file</span><br></pre></td></tr></table></figure>
<ul>
<li>u表示文件拥有者,g表示文件拥有者的群组(group),o表示其它以外的人,a表示三者都是.</li>
<li>+表示增加权限,-表示减少权限,=表示指定权限.</li>
</ul>
<h4 id="第二栏"><a href="#第二栏" class="headerlink" title="第二栏"></a>第二栏</h4><p>表示有多少档名连结到此节点(i-node)</p>
<h4 id="第三栏playcrab"><a href="#第三栏playcrab" class="headerlink" title="第三栏playcrab"></a>第三栏<code>playcrab</code></h4><p>表示文件的拥有者</p>
<h5 id="更换文件拥有者-chown"><a href="#更换文件拥有者-chown" class="headerlink" title="更换文件拥有者 chown"></a>更换文件拥有者 chown</h5><p><code>chown [拥有者][:群组] file</code><br>如<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost test6]# ll</span><br><span class="line">---xr--r-- 1 root users 302108 11-30 08:39 linklog.log</span><br><span class="line">---xr--r-- 1 root users 302108 11-30 08:39 log2012.log</span><br><span class="line">-rw-r--r-- 1 root users     61 11-30 08:39 log2013.log</span><br><span class="line">[root@localhost test6]# chown mail:mail log2012.log </span><br><span class="line">[root@localhost test6]# ll</span><br><span class="line">---xr--r-- 1 root users 302108 11-30 08:39 linklog.log</span><br><span class="line">---xr--r-- 1 mail mail  302108 11-30 08:39 log2012.log</span><br><span class="line">-rw-r--r-- 1 root users     61 11-30 08:39 log2013.log</span><br></pre></td></tr></table></figure></p>
<h4 id="第四栏-staff"><a href="#第四栏-staff" class="headerlink" title="第四栏 staff"></a>第四栏 <code>staff</code></h4><p>表示文件的所属组</p>
<h5 id="更改文件所属组-chgrp"><a href="#更改文件所属组-chgrp" class="headerlink" title="更改文件所属组 chgrp"></a>更改文件所属组 chgrp</h5><p>与chown类似,不过只更改群组<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root@localhost test]# ll</span><br><span class="line"></span><br><span class="line">---xrw-r-- 1 root root 302108 11-13 06:03 log2012.log</span><br><span class="line"></span><br><span class="line">[root@localhost test]# chgrp -v bin log2012.log</span><br><span class="line"></span><br><span class="line">“log2012.log” 的所属组已更改为 bin</span><br><span class="line"></span><br><span class="line">[root@localhost test]# ll</span><br><span class="line"></span><br><span class="line">---xrw-r-- 1 root bin  302108 11-13 06:03 log2012.log</span><br></pre></td></tr></table></figure></p>
<p>加上<code>-v</code>表示显示处理信息</p>
<h4 id="第五栏-6703"><a href="#第五栏-6703" class="headerlink" title="第五栏 6703"></a>第五栏 6703</h4><p>表示文件的大小,默认为byte</p>
<h4 id="第六栏-May-14-20-25"><a href="#第六栏-May-14-20-25" class="headerlink" title="第六栏 May 14 20:25"></a>第六栏 <code>May 14 20:25</code></h4><p>表示这个文件的建档日期或者是最近的修改日期</p>
<h4 id="第七栏-check-py"><a href="#第七栏-check-py" class="headerlink" title="第七栏 check.py"></a>第七栏 <code>check.py</code></h4><p>表示这个文件的档名<br>如果以<code>.</code>开头表示是隐藏文件</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>这两个图片是什么?可以扫吗?</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatPay.png" alt="Shen 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/aliPay.png" alt="Shen 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/linux/" rel="tag"># linux</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/06/14/fastJson反序列化时的问题/" rel="next" title="fastJson反序列化时的问题">
                <i class="fa fa-chevron-left"></i> fastJson反序列化时的问题
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/06/14/进制前缀/" rel="prev" title="进制前缀">
                进制前缀 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC80MjA1OS8xODYwNg=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
      <div id="sidebar-dimmer"></div>
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/saiki.jpeg" alt="Shen">
            
              <p class="site-author-name" itemprop="name">Shen</p>
              <p class="site-description motion-element" itemprop="description">Penn's blog</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">117</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">1</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">26</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#第一栏-drwxr-xr-x"><span class="nav-number">1.</span> <span class="nav-text">第一栏 drwxr-xr-x</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#文件类型"><span class="nav-number">1.1.</span> <span class="nav-text">文件类型</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#不同用户对文件的权限"><span class="nav-number">1.2.</span> <span class="nav-text">不同用户对文件的权限</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#可以通过chmod命令来执行权限-如"><span class="nav-number">1.3.</span> <span class="nav-text">可以通过chmod命令来执行权限,如:</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第二栏"><span class="nav-number">2.</span> <span class="nav-text">第二栏</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第三栏playcrab"><span class="nav-number">3.</span> <span class="nav-text">第三栏playcrab</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#更换文件拥有者-chown"><span class="nav-number">3.1.</span> <span class="nav-text">更换文件拥有者 chown</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第四栏-staff"><span class="nav-number">4.</span> <span class="nav-text">第四栏 staff</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#更改文件所属组-chgrp"><span class="nav-number">4.1.</span> <span class="nav-text">更改文件所属组 chgrp</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第五栏-6703"><span class="nav-number">5.</span> <span class="nav-text">第五栏 6703</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第六栏-May-14-20-25"><span class="nav-number">6.</span> <span class="nav-text">第六栏 May 14 20:25</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第七栏-check-py"><span class="nav-number">7.</span> <span class="nav-text">第七栏 check.py</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Shen</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("Gst71Gv0w5HKejm5H7LuG0XI-gzGzoHsz", "aoFAyHFDKihGTWWhHX0p8byC");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  

  

  

  

</body>
</html>
